﻿// Copyright 2012 T4C: sejerpz@gmail.com
// Licensed under GPL v3

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SET.Core
{
    class Interval
    {
        public int Octave1 { get; private set; }
        public int Octave2 { get; private set; }

        public string Note1 { get; private set; }
        public string Note2 { get; private set; }

        public Interval(int octave1, string note1, int octave2, string note2)
        {
            this.Octave1 = octave1;
            this.Octave2 = octave2;
            this.Note1 = note1;
            this.Note2 = note2;
        }

        public string Serialize()
        {
            return string.Format("{0},{1}-{2},{3}", Octave1, Note1, Octave2, Note2);
        }

        public override string ToString()
        {
            string n1, n2;
            if (Note1.EndsWith("#"))
                n1 = Messages.ResourceManager.GetString(Note1[0].ToString().ToValidIdentifier()) + Octave1 + "#";
            else
                n1 = Messages.ResourceManager.GetString(Note1.ToValidIdentifier()) + Octave1;

            if (Note2.EndsWith("#"))
                n2 = Messages.ResourceManager.GetString(Note2[0].ToString().ToValidIdentifier()) + Octave2 + "#";
            else
                n2 = Messages.ResourceManager.GetString(Note2.ToValidIdentifier()) + Octave2;

            return string.Format("{0} - {1}", n1, n2);
        }
    }
}
